package com.cs.study.homework._0223.Shop.controller;

import com.cs.study.homework._0223.Shop.model.Book;
import com.cs.study.homework._0223.Shop.view.BookView;

/**
 * @description:
 * @author: 景天
 * @date: 2024/2/23 14:44
 **/
// 控制器
public class BookController {
    // 定义成员变量
    private Book model;
    private BookView view;

    public BookController(Book model, BookView view) {
        this.model = model;
        this.view = view;
    }

    // 展示书籍信息
    public void display() {
        view.displayInfo(model);
    }

    // 更新书籍信息
    public void update(Book book) {
        // 更新model
        model.setBookName(book.getBookName());
        model.setAuthor(book.getAuthor());
        model.setPrice(book.getPrice());
        model.setBookId(book.getBookId());
        view.updateInfo();
    }

    public void delete(Book book) {
        view.deleteInfo();
    }
}
